package com.receive.consumer;

/**
 * Author wen
 * Date 2022-01-11
 */

import com.alibaba.fastjson.JSONObject;
import com.receive.entity.UserEntity;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

@Component
public class Consumer {
    @JmsListener(destination = "${queue}")//activeMq监听监听接收消息队列
    public void receive(String msg){//这个msg就是从消息队列获得到的参数
        System.out.println(msg);
        JSONObject jsonObject = new JSONObject();
        UserEntity userEntity = jsonObject.parseObject(msg,UserEntity.class);
        System.out.println(userEntity.getName()+"---"+userEntity.getId());
    }
}